/*
 * @Author: your name
 * @Date: 2022-02-28 21:05:40
 * @LastEditTime: 2022-02-28 23:20:01
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \test\websocket_server_main.cpp
 */
#include "websocket_server.h"


int main(){
    WORD wdVersion = MAKEWORD(2, 2);              //定义自己需要的网络库版本，这里是2.2
    WSADATA wdSockMsg;                            //这是一个结构体
    int nRes = WSAStartup(wdVersion, &wdSockMsg); //打开一个套接字
    if (0 != nRes)
    {
        switch (nRes)
        {
        case WSASYSNOTREADY:
            printf("check your library");
            break;
        case WSAVERNOTSUPPORTED:
            printf("need updated");
            break;
        case WSAEINPROGRESS:
            printf("need reboot");
            break;
        case WSAEPROCLIM:
            printf("sdfsdfsa");
            break;
        }
    }
    if (2 != HIBYTE(wdSockMsg.wVersion) || 2 != LOBYTE(wdSockMsg.wVersion))
    {
        printf("WSACleanup");
        WSACleanup();
        return 0;
    }
    
    WebsocketServer *p1 = new WebsocketServer("127.0.0.1",8001);
    int count = 0;
    while (1)
    {
        // std::cout<<"124"<<std::endl;
        Sleep(4000);
        p1->SendDataAllClient("123455",5,websocketpp::frame::opcode::TEXT);
        count++;
    }

}